<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var array = function (names, heights) {
      var b = [];
      var a = new Map()
      for (var c = 0; c < heights.length; c++) {
        a.set(heights[c], names[c])
      }
      heights.sort((a, b) => b - a)
      for (var i = 0; i < heights.length; i++) {
        b.push(a.get(heights[i]));

      }

      return b;

    };
    console.log(array(["Mary", "John", "Emma"], [180, 165, 170]))
  </script>
</body>

</html>